<template>
  <Sku v-if="dataLoaded" :goods = "goods" @sendData="getObject" />
</template>

<script setup>
import Sku from './Sku.vue'
import {ref, onMounted} from 'vue'
import axios from 'axios'
let dataLoaded = ref(false)//用来保证父组件数据得到之后才开始渲染子组件
const goods = ref('')
const objectFormSon = ref('')
const getGoods = async () => {
  // 1135076  初始化就有无库存的规格
  // 1369155859933827074 更新之后有无库存项（蓝色-20cm-中国）
  const res = await axios.get('http://pcapi-xiaotuxian-front-devtest.itheima.net/goods?id=1369155859933827074')
  // console.log(res)
  goods.value = res.data.result
  dataLoaded.value = true
  console.log(dataLoaded.value)
  console.log(goods.value, 'goods.value')
}
const getObject = (data) => {
  objectFormSon.value = data
  // console.log(objectFormSon.value, 'objectFormSon')
}
onMounted(() => {
  getGoods()
})
</script>

<style lang="scss" scoped>
  
</style>